#include <iostream>
#include <algorithm>
#include <string.h>
#include <vector>
#define lowbit(x) ((x) & (-(x)))
#define int long long
using namespace std;
const int inf = 0x3f3f3f3f3f3f3f3f;
int n, m, L, V;
struct Car {
    int s, a, v;
} A[100005];
vector<Car> v1;
vector<pair<int, int> > vec;
vector<pair<int, int> > kld;
int p[100005], pre[1000005];
struct BIT {
    int bit[1000005];
    void add(int x, int y) { for (++x; x; x -= lowbit(x)) bit[x] = min(bit[x], y); }
    int query(int x) {
        int ret = inf;
        for (++x; x <= 1000002; x += lowbit(x)) ret = min(ret, bit[x]);
        return ret;
    }
} bit;
int dp[100005];
signed main() {
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    int tc;
    cin >> tc;
    while (tc--) {
        v1.clear();
        vec.clear();
        kld.clear();
        memset(bit.bit, 63, sizeof bit.bit);
        memset(pre, 0, sizeof pre);
        cin >> n >> m >> L >> V;
        for (int i = 1; i <= n; i++) {
            cin >> A[i].s >> A[i].v >> A[i].a;
            if (A[i].v > V) 
                v1.emplace_back(A[i]);
            else if (A[i].a > 0) 
                v1.emplace_back(A[i]);
        }
        for (int i = 1; i <= m; i++) {
            cin >> p[i];
            pre[p[i]] = 1;
        }
        for (auto v : v1) {
            if (v.v > V && v.a < 0) 
                vec.emplace_back(make_pair(v.s, min(L, v.s + (v.v * v.v - V * V - 2 * v.a - 1) / (-2 * v.a) - 1)));
            else if (v.v <= V && v.a > 0) {
                int tmp = v.s + (V * V - v.v * v.v) / (2 * v.a) + 1;
                if (tmp <= L) 
                    vec.emplace_back(make_pair(tmp, L));
            } else 
                vec.emplace_back(make_pair(v.s, L));
        } 
        for (int i = 1; i <= L; i++) pre[i] += pre[i - 1];
        for (auto v : vec) {
            if (pre[v.second] != pre[v.first - 1]) 
                kld.emplace_back(v);
        }
        cout << kld.size() << " ";
        bit.add(0, 0);
        sort(kld.begin(), kld.end(), [](pair<int, int> a, pair<int, int> b) { return a.second < b.second; });
        p[m + 1] = L + 1;
        int cur = 0;
        for (int i = 1, j = 0; i <= m + 1; i++) {
            while (j < (int)kld.size() && kld[j].second < p[i]) cur = max(cur, kld[j++].first);
            dp[i] = bit.query(cur) + 1;
            bit.add(p[i], dp[i]);
        }
        cout << m - dp[m + 1] + 1 << "\n";
    }
    return 0;
}